/**
 */
package OBSL.impl;

import OBSL.OBSLPackage;
import OBSL.PresentIndividual;
import OBSL.SubParameter;

import RefOntoUML.Classifier;

import java.lang.reflect.InvocationTargetException;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Present Individual</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link OBSL.impl.PresentIndividualImpl#getAssignedTo <em>Assigned To</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public abstract class PresentIndividualImpl extends IndividualImpl implements PresentIndividual {
	/**
	 * The cached value of the '{@link #getAssignedTo() <em>Assigned To</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getAssignedTo()
	 * @generated
	 * @ordered
	 */
	protected SubParameter assignedTo;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected PresentIndividualImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return OBSLPackage.Literals.PRESENT_INDIVIDUAL;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public SubParameter getAssignedTo() {
		if (assignedTo != null && assignedTo.eIsProxy()) {
			InternalEObject oldAssignedTo = (InternalEObject)assignedTo;
			assignedTo = (SubParameter)eResolveProxy(oldAssignedTo);
			if (assignedTo != oldAssignedTo) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, OBSLPackage.PRESENT_INDIVIDUAL__ASSIGNED_TO, oldAssignedTo, assignedTo));
			}
		}
		return assignedTo;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public SubParameter basicGetAssignedTo() {
		return assignedTo;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetAssignedTo(SubParameter newAssignedTo, NotificationChain msgs) {
		SubParameter oldAssignedTo = assignedTo;
		assignedTo = newAssignedTo;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, OBSLPackage.PRESENT_INDIVIDUAL__ASSIGNED_TO, oldAssignedTo, newAssignedTo);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setAssignedTo(SubParameter newAssignedTo) {
		if (newAssignedTo != assignedTo) {
			NotificationChain msgs = null;
			if (assignedTo != null)
				msgs = ((InternalEObject)assignedTo).eInverseRemove(this, OBSLPackage.SUB_PARAMETER__REFERENCE_TO, SubParameter.class, msgs);
			if (newAssignedTo != null)
				msgs = ((InternalEObject)newAssignedTo).eInverseAdd(this, OBSLPackage.SUB_PARAMETER__REFERENCE_TO, SubParameter.class, msgs);
			msgs = basicSetAssignedTo(newAssignedTo, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, OBSLPackage.PRESENT_INDIVIDUAL__ASSIGNED_TO, newAssignedTo, newAssignedTo));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Classifier classifiedBy() {
		// TODO: implement this method
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case OBSLPackage.PRESENT_INDIVIDUAL__ASSIGNED_TO:
				if (assignedTo != null)
					msgs = ((InternalEObject)assignedTo).eInverseRemove(this, OBSLPackage.SUB_PARAMETER__REFERENCE_TO, SubParameter.class, msgs);
				return basicSetAssignedTo((SubParameter)otherEnd, msgs);
		}
		return super.eInverseAdd(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case OBSLPackage.PRESENT_INDIVIDUAL__ASSIGNED_TO:
				return basicSetAssignedTo(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case OBSLPackage.PRESENT_INDIVIDUAL__ASSIGNED_TO:
				if (resolve) return getAssignedTo();
				return basicGetAssignedTo();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case OBSLPackage.PRESENT_INDIVIDUAL__ASSIGNED_TO:
				setAssignedTo((SubParameter)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case OBSLPackage.PRESENT_INDIVIDUAL__ASSIGNED_TO:
				setAssignedTo((SubParameter)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case OBSLPackage.PRESENT_INDIVIDUAL__ASSIGNED_TO:
				return assignedTo != null;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eInvoke(int operationID, EList<?> arguments) throws InvocationTargetException {
		switch (operationID) {
			case OBSLPackage.PRESENT_INDIVIDUAL___CLASSIFIED_BY:
				return classifiedBy();
		}
		return super.eInvoke(operationID, arguments);
	}

} //PresentIndividualImpl
